home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Messaging / OSL / OSLPriv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  11.7 KB  |  404 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OSLPriv.h (Orignal name: OSLPrivate.h)
  3.  
  4.     Contains:    
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <7>     8/29/95    jpa        DescPtr --> AEDesc* for Univ Hdrs 2.1.
  13.                                     [1279173]
  14.          <6>     6/27/95    NP        1262792: new version of OSLObjectInit
  15.          <5>     6/23/95    NP        1195474: Make Resolve reentrant.
  16.          <4>      5/3/95    NP        1211084: Remove 5$
  17.          <3>     4/24/95    eeh        1212343: include HshTbTyp.h; remove dups
  18.          <2>     8/19/94    NP        1181622: Ownership fix.
  19.         <12>      5/2/94    eeh        bug #1160654: various PPC native changes
  20.         <11>      2/9/94    NP        Tiger Team cleanup.
  21.         <10>      2/7/94    NP        Tiger Team doings.
  22.          <9>    10/22/93    NP        Removed obsolete context parameter from
  23.                                     some functions.
  24.          <8>    10/18/93    NP        Added/changed functional interfaces to
  25.                                     correspond with code.
  26.          <7>    10/11/93    NP        Internal interface changes and additions.
  27.          <6>     9/20/93    NP        Removed GetCurrentContext and
  28.                                     SetCurrentContext from here. Put them in
  29.                                     CntxtOSL.h.
  30.          <5>     8/18/93    NP        Mods for new context scheme.
  31.          <4>     8/16/93    NP        Adjusted for latest OSL proposal.
  32.          <3>     7/28/93    NP        Mods for new token type, OSLToken.
  33.          <2>     7/21/93    NP        Fixed #includes.
  34.          <1>     7/21/93    NP        first checked in
  35.  
  36.     To Do:
  37.  
  38. */
  39.  
  40. /*                                            
  41.     ©Apple Computer, Inc.  1992-94         
  42.           All Rights Reserved.                
  43.     Author: Eric House
  44.                                             */
  45.  
  46. #ifndef _OSLPRIV_
  47. #define _OSLPRIV_
  48.  
  49. #ifndef __APPLEEVENTS__
  50. #include <AppleEvents.h>
  51. #endif
  52. #ifndef __AEOBJECTS__
  53. #include <AEObjects.h>
  54. #endif
  55. #ifndef __MIXEDMODE__
  56. #include <MixedMode.h>
  57. #endif
  58.  
  59. #ifndef __OSLTempdefs__
  60. #include "OSLTmpdf.h"
  61. #endif
  62. #ifndef _CNTXTOSL_
  63. #include "CntxtOSL.h"
  64. #endif
  65.  
  66. #ifndef _HSHTBTYP_
  67. #include "HshTbTyp.h"
  68. #endif
  69.  
  70. #define     kInitialHashTableSize 16
  71. #define     typeWhoseRangeInternal 'ind*'
  72.  
  73. #define     typeWhoseRangeInternal 'ind*'
  74.  
  75. #define     kAEAppDoesNothing    kAEIDoMinimum 
  76. #define     kAEAppDoesWhose        kAEIDoWhose 
  77. #define     kAEAppDoesAnyForms    kAEIDoWhose
  78.  
  79.  
  80. #define     kInitialHashTableSize    16 
  81.  
  82. #define     keyAEGetErrDescProc        'indc'
  83.  
  84. #define FailErr( res, err, lable )                                        \
  85.         if ( (err = (res)) != noErr )                                    \
  86.         {                                                                \
  87.             goto lable ;                                                \
  88.         }
  89.  
  90. #define    FAIL_ERR_PROC(err,lable)                                        \
  91.     return err ;                                                        \
  92. lable:                                                                    \
  93.     {
  94.  
  95. #define END_FAIL_ERR_PROC(err)                                            \
  96.     return err ;                                                        \
  97.     }
  98.  
  99. #define SizeOf sizeof
  100.  
  101. struct _TestTermRecord ;
  102. struct _ClassAndID ;
  103. struct _CompareEvtRecord ;
  104. struct _CompareRecord ;
  105. struct _LogicalRecord ;
  106. struct _IndexRecord ;
  107. struct _WhoseRecord ;
  108.  
  109.  
  110. struct _HashInfo {
  111.  long                     usedEntries ;
  112.  long                     collidedEntries ;
  113.  long                     totalEntries ;
  114.  long                     tableSize ;
  115. } ;
  116. typedef struct _HashInfo structHashInfo ;
  117.                 
  118. struct _ObjectAccessorKey {
  119.     DescType         firstKey ;
  120.     DescType         secondKey ;
  121. } ;
  122. typedef struct _ObjectAccessorKey ObjectAccessorKey ;
  123.  
  124. struct _ObjectAccessorValue {
  125.             OSLAccessorUPP         handler ;
  126.             long         handlerRefcon ;
  127. } ;
  128. typedef struct _ObjectAccessorValue ObjectAccessorValue ;
  129.         
  130.     
  131.     /* <eeh> Change to ObjRecord to accomodate new model: in certain cases that would
  132.       ordinarily call for two object records, one the container of the other, it is 
  133.       possible to combine them.  For instance, if an object's form is index and that
  134.       of its container is test and both are of the same class, then the two may be
  135.       combined into a single object.  We need a doubly-linked list for this type
  136.         of optimization. */
  137.  
  138. typedef struct _ObjRecord {
  139.     DescType         objClass ;                /*the desired class*/
  140.     struct _ObjRecord **objContainer ;                /*the container*/
  141.     struct _ObjRecord **objContained ;                /* makes it a doubly-linked list */
  142.     AEDesc         objSelectionData ;                    /*data to use in lookup*/
  143.     struct WhoseRecord **objTheWhose ;                    /*if it was a whose, this is the query structure
  144.                                             used only for nested whose clauses */
  145.     OSLToken         objValue ;                    /* result token */
  146.     Boolean         valIsExmn ;                /* is same as another token; don't dispose */
  147.     Boolean         objRedo ;                /* must be recalculated each time? */
  148.     AEDesc          theObjInput ;
  149.     union {
  150.         DescType objForm ;                /*how to get it*/
  151.         DescType    tokenClass;            /* could be union with objForm; we'll never use both */
  152.     } u ;
  153. } ObjRecord, *ObjRecordPtr, **Object ;
  154.  
  155. typedef enum testType {kCompare, kCompareEvt, kLogical} testType;
  156.     
  157. struct _TestTermRecord {
  158.     struct _TestTermRecord **next ;
  159.     Boolean         value ;
  160.     Boolean         redo ;
  161.     AEDesc          theTermInput ;
  162.     testType        ttype ; 
  163.     union {    
  164.         struct _LogicalRecord **log ;
  165.         struct _CompareEvtRecord **cEvt ;
  166.         struct _CompareRecord **compar;            // changed from "comp" because
  167.                                                 // compiler didn't like "comp"
  168.     } u ;
  169. } ;
  170. typedef struct _TestTermRecord TestTermRecord, *TestTermPtr, **Term ;
  171.  
  172. struct _ClassAndID {
  173.     DescType eventClass ;
  174.     DescType eventID ;
  175.     } ;
  176.  
  177. // <eeh> added 3/15
  178. struct _CompareEvtRecord {
  179.     AppleEvent        eventWParams ;
  180.     Boolean         value ;            /*result*/
  181.     Boolean         redo ;            /*must be recalculated each time?*/
  182.     AEDesc          theCompEvtInput ;
  183. } ;
  184. typedef struct _CompareEvtRecord CompareEvtRecord, *CompareEvtPtr, **CompareEvent ;
  185.  
  186. struct _CompareRecord {
  187.     Object            obj1 ;            /*left hand operand*/
  188.     Object            obj2 ;            /*right hand operand*/
  189.     DescType         oper  ;            /*> < <= etc.*/
  190.     
  191.     Boolean         value ;            /*result*/
  192.     Boolean         redo ;            /*must be recalculated each time?*/
  193.     AEDesc          theCompInput ;
  194. } ;
  195. typedef struct _CompareRecord CompareRecord, *ComparePtr, **Comparison ;
  196.  
  197. struct _LogicalRecord {
  198.     DescType         logicalOp ;            // AND, OR, NAND
  199.     Term            firstTerm ;            // start of linked list of terms
  200.     Boolean         value ;                // result
  201.     Boolean         redo ;                // must be recalculated each time?
  202.     AEDesc          theLogicalInput ;
  203. } ;
  204. typedef struct _LogicalRecord LogicalRecord, *LogicalPtr, **Logical ;
  205.     
  206.     
  207. struct _IndexRecord {
  208.  DescType         startCase ;        // for relative values instead of integers
  209.  long             startValue ;
  210.  DescType         stopCase ;        // for relative values instead of integers
  211.  long         stopValue ;
  212. } ;
  213. typedef struct _IndexRecord IndexRecord, *indexRecordPtr ;
  214.             
  215.  
  216. struct _WhoseRecord {
  217.  IndexRecord         index ;                // which matching objects desired
  218.  Term         theTerm ;                    // test to match against
  219.  OSLToken         whoseValue ;            // result token
  220.  AEDesc          theWhoseInput ;
  221. } ;
  222. typedef struct _WhoseRecord WhoseRecord, *WhoseRecordPtr, **Whose ;
  223.  
  224. typedef DescType *DescTypePtr, **DescTypeHandle ;
  225. typedef long *LongPtr, **LongHandle ;
  226.  
  227. struct _aeh {
  228.     ProcPtr                     DerefProc ;
  229.     ProcPtr                     NewProc ;
  230.     ProcPtr                     GrowProc ;
  231.     ProcPtr                     DisposeProc ;
  232.     } ;
  233. typedef struct _MemProcBlock MemProcBlock ;
  234. //typedef MemProcBlock* OSLMemProcs ;
  235.  
  236. struct _GlobalRec {
  237.     HHand                 aeHashTable ;
  238.     HHand                 coercionHashTable ;
  239.     HHand                 accessorHashTable ;
  240.     ProcPtr             phacProcPtr ;
  241.     ProcPtr             selhProcPtr ;
  242.     ProcPtr             blockingPtr ;
  243.     ProcPtr             unblockingPtr ;
  244.     OSLDisposeTokenUPP     diposeTokenProcPtr ;
  245.     OSLCompareUPP        compareProcPtr ;
  246.     OSLCountUPP            countProcPtr ;
  247.     OSLGetMarkTokenUPP     getMarkIDProcPtr ;
  248.     OSLMarkUPP             MarkProcPtr ;
  249.     OSLAdjustMarksUPP     AdjustMarksProcPtr ;
  250.     ProcPtr             AENonAevtHandler ;
  251.     OSLGetErrDescUPP     TypeAsIndexProc ;
  252. } ;
  253. typedef struct _GlobalRec GlobalRec, *GlobalRecPointer, **GlobalRecHandle ;
  254.  
  255. extern pascal OSErr SelectorDispatch(void) ;
  256.  
  257.  
  258. //pascal GlobalRecHandle GetGlobalRef(void) =
  259. //    { 0x2078, 0x02B6, 0x2EA8, 0x0154} ; 
  260. // movea.l expandMem,a0; move.l $154(a0),(a7) 
  261.     
  262. //pascal GlobalRecHandle GetSysGlobal(void) = 
  263. //    { 0x2078, 0x02B6, 0x2EA8, 0x017C } ;
  264. //movea.l expandMem,a0; move.l $17C(a0),(a7) }
  265.  
  266. //0x2B6 is the old ExpandMem (not defined in the system headers anymore!)
  267. #define GetGlobalRef() (GlobalRecHandle)(*((long *)((*((char **)0x2B6)) + 0x154)))
  268. #define GetSysGlobal() (GlobalRecHandle)(*((long *)((*((char **)0x2B6)) + 0x17C)))
  269.  
  270. #define IgnoreOSErr(x) x
  271.  
  272.  
  273. // a version for C OSErr functions: just drop it altogether.
  274. #define CIgnoreOSErr(call)             call
  275.  
  276. //==============================================================================
  277. // Functions
  278. //==============================================================================
  279.  
  280. // Implemented in glue that calls through to Apple Event Mgr undocumented calls.
  281.  
  282. extern OSErr CreateObject( const AEDesc *input, Object containedObj,
  283.         Boolean expandWhoseData, Object *theObject ) ;
  284.  
  285. extern OSErr CreateWhose( AEDesc input, Whose *theWhose ) ;
  286.  
  287. extern OSErr CreateTerm( AEDesc *input, Term *theTerm ) ;
  288.  
  289. extern OSErr CreateCompare( AEDesc  input , Comparison *theComparison ) ;
  290.  
  291. extern OSErr CreateLogical( const AEDesc *input , Logical *theLogical ) ;
  292.  
  293. extern void DisposeObj( Object o ) ;
  294.  
  295. extern void DisposeWhose( Whose w ) ;
  296.  
  297. extern void DisposeTerm( Term t ) ;
  298.  
  299. extern void DisposeLogical( Logical l ) ;
  300.  
  301. extern void DisposeCompare( Comparison c ) ;
  302.  
  303. extern void MakeNull(AEDesc *theDesc ) ;
  304. extern void MakeNullToken(OSLToken *theToken ) ;
  305. extern OSErr EvalObj( Object o , DescType exmnClass , OSLToken *objectBeingExmn,
  306.     short appDoesFlags) ;
  307.  
  308. extern OSErr CallCompareProc(  DescType oper, OSLToken obj1 ,
  309.     OSLToken obj2, Boolean *result ) ;
  310. OSErr NewCallCompareProc(DescType            oper,
  311.                             OSLToken        obj1,
  312.                             OSLToken        obj2,
  313.                             Boolean*        result);
  314. extern OSErr CallAdjustMarks( long newStart, long newStop,
  315.         OSLToken markToken ) ;
  316. OSErr NewCallAdjustMarks( long newStart, long newStop,
  317.         OSLToken markToken ) ;
  318. extern OSErr CallMark( OSLToken dToken, OSLToken  markToken, long n ) ;
  319. OSErr NewCallMark( OSLToken dToken, OSLToken  markToken, long n ) ;
  320. extern OSErr CallGetMarkToken( OSLToken dContainerToken,
  321.         DescType containerClass, OSLToken *result ) ;
  322. OSErr NewCallGetMarkToken( OSLToken dContainerToken,
  323.         DescType containerClass, OSLToken *result ) ;
  324. extern OSErr
  325. CallCountProc( DescType desiredType, DescType containerClass,
  326.         OSLToken container, long *result ) ;
  327. OSErr NewCallCountProc(DescType        desiredType,
  328.                         DescType    containerClass,
  329.                         OSLToken    container,
  330.                         long*        result);
  331. extern pascal OSErr
  332. iCallAccessor( DescType  wantType , OSLToken  container ,
  333.         DescType  containerClass , DescType form,
  334.          AEDesc selectionData , OSLToken *value ) ;
  335. extern OSErr CallGetErrDesc( AEDesc* *appDescPtr ) ;
  336. OSErr NewCallGetErrDesc( AEDesc* *appDescPtr ) ;
  337.  
  338. extern pascal OSErr
  339. iAEDisposeToken( OSLToken *theDesc ) ;    
  340. OSErr NewCallDisposeToken(OSLToken* theToken);
  341.  
  342. extern pascal OSErr
  343. iAEObjectInit(OSLContext* context);
  344.  
  345. static void
  346. zero( char *s, long bytes ) ;
  347.  
  348. extern OSErr            // EvalObj needs this guy
  349. InternalResolve    (    Object         thisObj ,    
  350.                      DescType    exmnClass ,
  351.                     OSLToken    *dObjExamined ,
  352.                     Boolean        *contIsExmn ,
  353.                     OSLToken    *value ,
  354.                     Boolean        *redo ) ;
  355.  
  356. OSErr GetExmn( OSLToken *result ) ; // what effect does this have?
  357. OSErr SetExmn( OSLToken *newDesc ) ;
  358. // I'm not sure the OSL needs this next guy
  359. OSErr SwapExmn( AEDesc *oldAndNewDesc ) ;
  360.  
  361. OSErr AddContextToTopOfStack(OSLContext* context);
  362. OSErr RemoveTopOfContextStack();
  363.  
  364. Boolean SetErrDesc( AEDesc failedDesc );
  365. OSErr
  366. EvalWhose( Whose whoz , DescType  wantClass , DescType  containerClass ,
  367.         OSLToken  container , short appDoesFlags );
  368.  
  369. pascal OSErr
  370. iAEGetObjectAccessor(    DescType        desiredClass,
  371.                         DescType        containerType,
  372.                         OSLAccessorUPP    *handler,
  373.                         long             *handlerRefcon,
  374.                         Boolean            isSysHandler);
  375.                         
  376. pascal OSErr
  377. iAEInstallObjectAccessor(DescType            desiredClass ,
  378.                         DescType            containerType ,
  379.                         OSLAccessorUPP        handler ,
  380.                         long                handlerRefcon ,
  381.                         Boolean                isSysHandler);
  382.  
  383. pascal OSErr
  384. InternalDisposeToken( OSLToken* token );
  385.  
  386. pascal OSErr
  387. iAEDisposeToken( OSLToken *theDesc );
  388.  
  389. pascal OSErr
  390. iAEResolve(    AEDesc dObjectSpecifier, OSLToken *dTheToken, OSLContext* startingContext);
  391.  
  392. OSErr GetAppDoesFlags(OSLContext* token, short* appDoesFlags);
  393.  
  394. OSErr MakeExternalWhose( const AEDesc* desc, AEDesc *result ) ;
  395.  
  396. // ISSUES
  397. // 1. Need to search all files for uses of IgnoreOSErr, and make sure it is
  398. // only used on functions of type pascal.  A different one needs to be written
  399. // (for consistency's sake only, since C lets me ignore returned values)
  400. // for C functions.
  401.  
  402. #endif // _OSLPRIV_
  403.  
  404.